package IO.BIO;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    static byte[] bs = new byte[1024];

    public static void main(String[] args) throws IOException {

        //它只是一个监听机制
        ServerSocket serverSocket = new ServerSocket(9098);
        while (true) {
            System.out.println("开始阻塞");
            //阻塞 放弃CPU
            //当监听到有人连接就会返回一个新的socket
            Socket clientSocket = serverSocket.accept();
            System.out.println("连接成功");
            //输入流，字面理解从外部输入
            //阻塞，放弃CPU
            clientSocket.getInputStream().read(bs);
            System.out.println("data success");
            System.out.println(new String(bs));
        }
    }
}